package com.wdf.dota;

import java.io.InputStream;

import com.wdf.bean.Info;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Html;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;

public class HeroViewActivity extends Activity {


	

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.hero_info);

		try {
		Bundle bundle = this.getIntent().getExtras();
		String heroname =	bundle.getString("heroname");
		String description	=bundle.getString("herodescription");
		String prop = bundle.getString("heroprop");
		String skill1=	bundle.getString("skill1");
		String skill2 =	bundle.getString("skill2");
		String skill3 = bundle.getString("skill3");
		String skill4 =	bundle.getString("skill4");
		String modinfo678 = bundle.getString("modinfo");
		
		    ImageView  heromap= (ImageView ) findViewById(R.id.heromap);
			TextView herodescription= (TextView) findViewById(R.id.herodescription);
			TextView heroprop = (TextView) findViewById(R.id.heroprop);
			ImageView  skill1map= (ImageView ) findViewById(R.id.skill1map);
			TextView skill1description= (TextView) findViewById(R.id.skill1description);
			ImageView  skill2map = (ImageView ) findViewById(R.id.skill2map);
			TextView skill2description = (TextView) findViewById(R.id.skill2description);
			ImageView  skill3map = (ImageView ) findViewById(R.id.skill3map);
			TextView skill3description = (TextView) findViewById(R.id.skill3description);
			ImageView  skill4map = (ImageView ) findViewById(R.id.skill4map);
			TextView skill4description = (TextView) findViewById(R.id.skill4description);
			TextView dota678modification = (TextView) findViewById(R.id.dota678modification);
			
			herodescription.setText(Html.fromHtml(description));
			heroprop.setText(Html.fromHtml(prop));
			skill1description.setText(Html.fromHtml(skill1));
			skill2description.setText(Html.fromHtml(skill2));
			skill3description.setText(Html.fromHtml(skill3));
			skill4description.setText(Html.fromHtml(skill4));
			dota678modification.setText(Html.fromHtml(modinfo678));
			
			String skill1Path = heroname+"_skill1.png"; 
			String skill2Path = heroname+"_skill2.png"; 
			String skill3Path = heroname+"_skill3.png"; 
			String skill4Path = heroname+"_skill4.png"; 

			int resID = getResources().getIdentifier(heroname, "drawable", "com.wdf.dota"); 
			Drawable image = getResources().getDrawable(resID);
			heromap.setBackgroundDrawable(image);
			InputStream fis1 = getAssets().open( skill1Path);
            Bitmap bm1 = BitmapFactory.decodeStream(fis1);
            skill1map.setImageBitmap(bm1);
			InputStream fis2 = getAssets().open( skill2Path);
            Bitmap bm2 = BitmapFactory.decodeStream(fis2);
            skill2map.setImageBitmap(bm2);
			InputStream fis3 = getAssets().open( skill3Path);
            Bitmap bm3 = BitmapFactory.decodeStream(fis3);
            skill3map.setImageBitmap(bm3);
			InputStream fis4 = getAssets().open( skill4Path);
            Bitmap bm4 = BitmapFactory.decodeStream(fis4);
            skill4map.setImageBitmap(bm4);
            
        
            
            Info info =new Info();
  
            String[] jiadian= info.getClass().getField(heroname).get(info).toString().split("-");
            String[] start = info.getClass().getField(heroname+"_1").get(info).toString().split("-");
            String[] medium = info.getClass().getField(heroname+"_2").get(info).toString().split("-");
            String[] end = info.getClass().getField(heroname+"_3").get(info).toString().split("-");
            
            for(int i= 0;i< jiadian.length; i++){
            	ImageView  jiadianmap = (ImageView ) findViewById(getResources().getIdentifier("jiadian"+(i+1), "id", "com.wdf.dota"));
            	String jiadianpath = "";
            	if("0".equals(jiadian[i])){
            		jiadianpath = "skill.png";
            	}else{
            		jiadianpath =heroname+ "_skill"+jiadian[i]+".png";
            	}
            	InputStream fis = getAssets().open( jiadianpath);
                Bitmap bm = BitmapFactory.decodeStream(fis);
                jiadianmap.setImageBitmap(bm);
            }
            
            for(int i= 0;i< start.length; i++){
            	ImageView  startequipmentmap = (ImageView ) findViewById(getResources().getIdentifier("startequipment"+(i+1), "id", "com.wdf.dota"));
            	int id = getResources().getIdentifier("store"+start[i], "drawable", "com.wdf.dota"); 
    			Drawable startequipmentDrawable = getResources().getDrawable(id);
    			startequipmentmap.setBackgroundDrawable(startequipmentDrawable);
    			
            }
            for(int i= 0;i< medium.length; i++){
            	ImageView  mediumequipmentmap = (ImageView ) findViewById(getResources().getIdentifier("mediumequipment"+(i+1), "id", "com.wdf.dota"));
            	int id = getResources().getIdentifier("store"+medium[i], "drawable", "com.wdf.dota"); 
    			Drawable mediumequipmentDrawable = getResources().getDrawable(id);
    			mediumequipmentmap.setBackgroundDrawable(mediumequipmentDrawable);
    			
            }
            
            for(int i= 0;i< end.length; i++){
            	ImageView  endequipmentmap = (ImageView ) findViewById(getResources().getIdentifier("endequipment"+(i+1), "id", "com.wdf.dota"));
            	int id = getResources().getIdentifier("store"+end[i], "drawable", "com.wdf.dota"); 
    			Drawable endequipmentDrawable = getResources().getDrawable(id);
    			endequipmentmap.setBackgroundDrawable(endequipmentDrawable);
    			
            }
            

            
		} catch (Exception e) {
		}
		
		
	}
}
